package cn.dkdoo.utils.config.transactionInfo;

import cn.dkdoo.utils.common.ThreadLocalPool;

/**
 * Created by Nicky.Tang on 2021/5/10 11:04 下午
 *
 * @since 02.12.10
 */
public class TransactionInfoDefault extends TransactionInfoAbstract {

    // 这个属性很重要，只有新事物，才会执行回滚
    private transient final boolean newTransaction;
    private transient final String traNo;

    public TransactionInfoDefault(boolean newTransaction, String traNo) {
        this.newTransaction = newTransaction;
        this.traNo = traNo;
    }

    public TransactionInfoDefault(boolean newTransaction) {
        this.newTransaction = newTransaction;
        this.traNo = ThreadLocalPool.TRA_NO_MANAGER.getCur();
    }

    @Override
    public String getTraNo() {
        return this.traNo;
    }

    @Override
    public boolean checkIsNewTransaction() {
        return newTransaction;
    }

    @Override
    public Object getConnection() {
        return null;
    }

}
